<?php
header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE');
// 响应头设置
header('Access-Control-Allow-Headers:x-requested-with,Content-Type,X-CSRF-Token');
include "./mysql.php";
$username = $_POST["username"];
$password = $_POST['password'];
$email = $_POST["usernameemail"];

$sql  = "INSERT INTO t_users (username,password,nickname,email) VALUES ('${username}','${password}','${password}','${email}')";

$result = $mysqli->query($sql);

if ($mysqli->affected_rows) {
    $arr = array("code" => "200", "msg" => "注册成功");
} else {
    $arr = array("code" => "404", "msg" => "注册失败");
}
echo (json_encode($arr));


